<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.LinkedObjectsInfoContainer" var="TYPE_PAGE" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.LinkedObjectsInfoContainer" var="TYPE_RESOURCE" />

<atleap:isUserInRole roles="core-linkedObjects-view" var="canViewLinkedObjects" />

<atleap:content identifier="information" ignore="true" />
<table cellpadding="0" cellspacing="0" border="0" class="tableView">
	<tr>
		<th>
			<atleap:message key="core.page.form.title" />
		</th>
		<td>
			<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:&nbsp;<atleap:fieldValue valueMap="${requestScope.contentPage.title}" language="${contentLocale.identifier}" complexSearch="false" />
				</div>
			</atleap:iterator>
		</td>
	</tr>
	<tr>
		<th>
			<atleap:message key="core.page.form.description" />
		</th>
		<td>
			<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:&nbsp;<atleap:fieldValue valueMap="${requestScope.contentPage.description}" language="${contentLocale.identifier}" complexSearch="false" />
				</div>
			</atleap:iterator>
		</td>
	</tr>
	<tr>
		<th>
			<atleap:message key="core.page.form.keywords" />
		</th>
		<td>
			<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:&nbsp;<atleap:fieldValue valueMap="${requestScope.contentPage.keywords}" language="${contentLocale.identifier}" complexSearch="false" />
				</div>
			</atleap:iterator>
		</td>
	</tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.page.form.uri" /></th>
        <td><c:out value="${requestScope.contentPage.uri}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.contentPage.form.layout" /></th>
        <td><c:out value="${requestScope.contentPage.layout.name}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.contentPage.form.roles" /></th>
        <td><c:out value="${requestScope.contentPage.rolesAsString}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.contentPage.form.cacheMaxAge" /></th>
        <td><c:out value="${requestScope.contentPage.cacheMaxAge}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left"><atleap:message key="core.contentPage.form.publicationDate" /></th>
        <td><atleap:formatDate value="${requestScope.contentPage.publicationDate}" /></td>
    </tr>
    <tr>
        <th align="left"><atleap:message key="core.contentPage.form.expirationDate" /></th>
        <td><atleap:formatDate value="${requestScope.contentPage.expirationDate}" /></td>
    </tr>
    <c:if test="${canViewLinkedObjects}">
        <tr>
            <td colspan="2" align="right">
                <atleap:rewriteUrl action="core/contentPage/view" var="thisRedirectUrl" >
                    <atleap:param name="id" value="${requestScope.contentPage.id}" />
                </atleap:rewriteUrl>
                <atleap:link action="core/linkedObjects/view?id=${requestScope.contentPage.id}&type=${TYPE_PAGE}&justView=true">
                    <atleap:param name="redirectUrl" value="${thisRedirectUrl}" />
                    <atleap:message key="core.commons.buttons.viewLinkedObjects" />
                </atleap:link>
            </td>
        </tr>
    </c:if>
</table>
<atleap:form action="core/contentPage/callUpdate" method="GET" validateOnSubmit="false">
    <html:hidden property="id" value="${requestScope.contentPage.id}" />
    <atleap:isUserInRole roles="core-contentPage-update">
        <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.callUpdate" /></atleap:submit>
    </atleap:isUserInRole>
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.showList" /></atleap:cancel>
</atleap:form>

<c:set var="ownerId" value="${requestScope.contentPage.id}" scope="request" />

<atleap:isUserInRole roles="core-contentField-list">
    <%-- List of content fields for this page --%>
    <c:set var="ownerIsCP" value="true" scope="request" />
    <h3>
        <atleap:message key="core.contentField.list.page" />
    </h3>
    <tiles:get name="listContentFields" />
</atleap:isUserInRole>

<atleap:isUserInRole roles="core-sequence-list">
    <%-- List of sequences for this page --%>
    <h3>
        <atleap:message key="core.sequence.list.page" />
    </h3>
    <tiles:get name="listSequences" />
</atleap:isUserInRole>

<atleap:isUserInRole roles="core-menuItem-list">
    <%-- List of menu items for this page --%>
    <h3>
        <atleap:message key="core.menuItem.list" />
    </h3>
    <atleap:content identifier="menuItemListInfo" ignore="true" />
    <tiles:get name="listMenuItems" />
</atleap:isUserInRole>
